package com.xxxx.comment.interceptor;

import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.util.StringUtils;
import org.springframework.web.filter.OncePerRequestFilter;
import java.io.IOException;

/**
 * @author lzf
 * @date 2023/8/29 17:25:37
 */
public class LoginFilter extends OncePerRequestFilter
{

    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException
    {
        String token = request.getHeader("Authorization");
        if (!StringUtils.hasText(token))
            filterChain.doFilter(request, response);
        // 解析token，获取载荷
        filterChain.doFilter(request, response);
    }
}
